package com.web.java0324mybatis;

import com.web.java0324mybatis.entity.Dept;
import com.web.java0324mybatis.entity.Staf;
import com.web.java0324mybatis.entity.Student;
import com.web.java0324mybatis.entity.StudentClass;
import com.web.java0324mybatis.mapper.DeptMapper;
import com.web.java0324mybatis.mapper.StafMapper;
import com.web.java0324mybatis.mapper.StudentClassMapper;
import com.web.java0324mybatis.mapper.StudentMapper;
import jakarta.annotation.Resource;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;

import java.util.List;

@SpringBootTest
class Java0324mybatisApplicationTests {

    @Resource
    StudentMapper studentMapper;

    @Test
    void testStudentMapper() {
        // Student student = new Student(17,"老张",200,"男","1566777866","武汉","421023200504017931");
        //      studentMapper.insertStudent(student);
        //     studentMapper.updateStudent(student);
        //     studentMapper.deleteStudent(17);
        List<Student> students = studentMapper.selectStudents();
        for (Student student : students) {
            System.out.println(student);
            System.out.println(student.getStudentClass());
        }
    }

    @Resource
    StudentClassMapper studentClassMapper;

    @Test
    void testStudentClassMapper(){
        StudentClass studentClass = studentClassMapper.selectStudentClassById(1);
        System.out.println(studentClass);
        System.out.println(studentClass.getStudents());
    }

    @Resource
    StafMapper stafMapper;

    @Test
    void testStafMapper() {
            List<Staf> stafs = stafMapper.selectstaf();
        for (Staf staf : stafs) {
            System.out.println(staf);
            System.out.println(staf.getDept());
        }
    }

    @Resource
    DeptMapper deptMapper;

    @Test
    void testDeptMapper() {
       Dept dept = deptMapper.selectDept(1);
       System.out.println(deptMapper);
        System.out.println(dept.getStafs());
    }

}